package com.wyh.mapper;

import com.wyh.entity.Activity;
import com.wyh.utils.sqlUtils.activity.addActivitySqlDynamic;
import com.wyh.utils.sqlUtils.activity.findActivitySqlDynamic;
import com.wyh.utils.sqlUtils.activity.updateActivitySqlDynamic;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ActivityMapper {
    //添加活动 todo organizer_user_if_fk使用用户名添加
    @InsertProvider(type = addActivitySqlDynamic.class , method = "addDynamic")
    void addActivity(Activity activity);
    //修改活动 todo organizer_user_if_fk使用用户名添加
    //查找活动信息byId
    @SelectProvider(type = findActivitySqlDynamic.class , method = "findDynamic")
    String selectActivityByIdOrName(Activity activity);
    //get all
    @Select("SELECT id,activity.name,type,time,address,organizer_user_id_fk,u.Username,activity.remark FROM activity left join communitymanagementsystem.user_activity ua on activity.id = ua.activity_id left outer join communitymanagementsystem.user u on activity.id = u.uid")
    List<Activity> getAllActivity();

    @Select("select id,activity.name,type,time,address,organizer_user_id_fk,u.Username,activity.remark FROM activity left join communitymanagementsystem.user_activity ua on activity.id = ua.activity_id left join communitymanagementsystem.user u on activity.id = u.uid")
    Activity findActivityById(int id);

    //删除活动
    @Delete("DELETE FROM activity WHERE id = #{text}")
    void deleteActivity(int text);

    @UpdateProvider( type = updateActivitySqlDynamic.class , method = "updateDynamic")
    void updateActivity(Activity activity);


}
